package com.springboot.middleware.middleware_grab_red_envelopes.model.mapper;

import com.springboot.middleware.middleware_grab_red_envelopes.model.entity.RedRecord;
import com.springboot.middleware.middleware_grab_red_envelopes.model.entity.RedRecordExample;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Repository
@Mapper
public interface RedRecordMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    long countByExample(RedRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int deleteByExample(RedRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int insert(RedRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int insertSelective(RedRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    List<RedRecord> selectByExample(RedRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    RedRecord selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int updateByExampleSelective(@Param("record") RedRecord record, @Param("example") RedRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int updateByExample(@Param("record") RedRecord record, @Param("example") RedRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int updateByPrimaryKeySelective(RedRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table red_record
     *
     * @mbg.generated Mon Jan 03 14:52:59 CST 2022
     */
    int updateByPrimaryKey(RedRecord record);

    /**
     * 根据用户id和红包全局唯一标识串获取RedRecord
     *
     * @param userId    用户id
     * @param redPacket 红包全局唯一标识串
     */
    @Select("select * from red_record where user_id = #{userId} and red_packet = #{redPacket}")
    RedRecord selectIdByUserIdAndRedPacket(@Param("userId") Integer userId, @Param("redPacket") String redPacket);
}